#include "Sphere.h"

/*!
  The constructor of the Sphere element
  @r: Radius of the shere
  @c: color of the sphere
  @m: the initial matrix of the element
  */
Sphere::Sphere(float r, unsigned char *c, float *m)
{
    if (m)
    {
	for (int i = 0; i < 4 * 4; ++i)
	{
	    _m[i] = m[i];
	}
    }
    else
    {
	for (int i = 0; i < 4 * 4; ++i)
	{
	    _m[i] = 0.0;
	}

        _m[0] = 1.0;
        _m[5] = 1.0;
        _m[10] = 1.0;
        _m[15] = 1.0;
    }

    color[0] = c[0];
    color[1] = c[1];
    color[2] = c[2];

    radius = r;
}

/*!
  The actual rendering of the sphere
  */
void Sphere::renderInLocalFrame() const
{
    glScalef(radius, radius, radius);
    glColor3ubv(color);
    glutSolidSphere(1, 100, 100);
}
